package com.ruoyi.insect.service.impl;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.insect.mapper.DiseaseRecordMapper;
import com.ruoyi.insect.domain.DiseaseRecord;
import com.ruoyi.insect.service.IDiseaseRecordService;

/**
 * 病虫害识别记录Service业务层处理
 *
 * @author
 * @date 2024-07-07
 */
@Service
public class DiseaseRecordServiceImpl implements IDiseaseRecordService
{
    @Autowired
    private DiseaseRecordMapper diseaseRecordMapper;

    /**
     * 查询病虫害识别记录
     *
     * @param id 病虫害识别记录ID
     * @return 病虫害识别记录
     */
    @Override
    public DiseaseRecord selectDiseaseRecordById(Long id)
    {
        return diseaseRecordMapper.selectDiseaseRecordById(id);
    }

    /**
     * 查询病虫害识别记录列表
     *
     * @param diseaseRecord 病虫害识别记录
     * @return 病虫害识别记录
     */
    @Override
    public List<DiseaseRecord> selectDiseaseRecordList(DiseaseRecord diseaseRecord)
    {
        return diseaseRecordMapper.selectDiseaseRecordList(diseaseRecord);
    }

    /**
     * 新增病虫害识别记录
     *
     * @param diseaseRecord 病虫害识别记录
     * @return 结果
     */
    @Override
    public int insertDiseaseRecord(DiseaseRecord diseaseRecord)
    {
        // 设置默认识别时间为当前时间
        if (diseaseRecord.getRecognitionTime() == null) {
            diseaseRecord.setRecognitionTime(new Date());
        }
        return diseaseRecordMapper.insertDiseaseRecord(diseaseRecord);
    }

    /**
     * 修改病虫害识别记录
     *
     * @param diseaseRecord 病虫害识别记录
     * @return 结果
     */
    @Override
    public int updateDiseaseRecord(DiseaseRecord diseaseRecord)
    {
        return diseaseRecordMapper.updateDiseaseRecord(diseaseRecord);
    }

    /**
     * 批量删除病虫害识别记录
     *
     * @param ids 需要删除的病虫害识别记录ID
     * @return 结果
     */
    @Override
    public int deleteDiseaseRecordByIds(Long[] ids)
    {
        return diseaseRecordMapper.deleteDiseaseRecordByIds(ids);
    }

    /**
     * 删除病虫害识别记录信息
     *
     * @param id 病虫害识别记录ID
     * @return 结果
     */
    @Override
    public int deleteDiseaseRecordById(Long id)
    {
        return diseaseRecordMapper.deleteDiseaseRecordById(id);
    }
}
